package com.cqhilink.iot.jobstandardmanagement.facade.service.operateunit;

import com.alibaba.fastjson.JSONObject;
import com.cqhilink.iot.jobstandardmanagement.facade.model.*;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * Created by YuPeng on 2017/1/7.
 * 操作步骤服务实现类
 */
public interface JsmOperateUnitService {
    /**
     * 获取步骤分页列表
     *
     * @param singleWorkStep
     * @return
     * @throws Exception
     */
    JSONObject getStep(SingleWorkStep singleWorkStep) throws Exception;

    /**
     * 获取单个步骤对象
     *
     * @param stepId
     * @return
     * @throws Exception
     */
    SingleWorkStep getStep(String stepId) throws Exception;

    /**
     * 新增步骤
     * @return  有附件上传
     * @throws  Exception
     */
    Map<String, Object> addStep(SingleWorkStep singleWorkStep,Employee employee) throws Exception;

    /**
     * 修改步骤
     *
     * @param singleWorkStep
     * @return
     * @throws Exception
     */
    Map<String, Object> modifyStep(SingleWorkStep singleWorkStep,Employee employee) throws Exception;

    /**
     * 删除单个步骤
     *
     * @param stepIds
     * @return
     * @throws Exception
     */
    Map<String, Object> delStep(String stepIds) throws Exception;


    /**
     *
     * @param stepIds 操作步骤，修改版本问题
     * @param versionNumber
     * @return
     * @throws Exception
     */
    Map<String, Object> insertStepVersion(String stepIds, BigDecimal versionNumber) throws Exception;

    /**
     * 批量删除步骤
     *
     * @param stepIds
     * @param cellId  操作单元ID
     * @return
     * @throws Exception
     */
    Map<String, Object> delStepBatch(String[] stepIds, String cellId) throws Exception;

    /**
     * 导入步骤EXCEL
     *
     * @param
     * @param cellId
     * @param
     * @return
     * @throws Exception
     */
    Map<String, Object> importStep(String cellId,List<SingleWorkStep> workCard,EmployeeVo employee) throws Exception;

    /**
     * 上移、下移操作步骤{操作单元}
     * @param singleWorkSteps
     * @return
     * @throws Exception
     */
    Map<String, Object> moveStep(List<SingleWorkStep> singleWorkSteps) throws Exception;

    /**
     * @param version 当前版本基本信息
     * @param oldVersion 当前在用版本号
     */
    Map<String,Object> cloneStep(Version version,BigDecimal oldVersion,Employee employee) throws Exception;

    /**
     * @param workCellInfo 操作单元
     * @param workCellInstance 一站一案
     * 将操作单元 步骤复制到一站一案
     */
    Map<String,Object> cloneStep(WorkCellInfo workCellInfo, WorkCellInstance workCellInstance,Employee employee) throws Exception;

    /**
     * @param oldInstance 原来一站一案基本信息
     * @param newInstance 新一站一案基本信息
     * @param employeeVo 复制人员基本信息
     */
    Map<String,Object> cloneStep(WorkCellInstance oldInstance, WorkCellInstance newInstance,EmployeeVo employeeVo) throws Exception;



    /*
   ------------以下是数据项操作方法------------------------------------------------------------------
     */

    /**
     * 获取数据项明细list
     *
     * @param stepId
     * @return
     * @throws Exception
     */
    List<SingleWorkStepDataItem> getDataItem(String stepId);

    /**
     * 批量添加数据项
     *
     * @param dataItem
     * @return
     * @throws Exception
     */
    Map<String, Object> addDataItem(SingleWorkStepDataItem[] dataItem,Employee employee) throws Exception;

    /**
     * 修改数据项
     *
     * @param dataItem
     * @return
     * @throws Exception
     */
    Map<String, Object> modifyDataItem(SingleWorkStepDataItem dataItem,Employee employee) throws Exception;

    /**
     * 删除数据项
     *
     * @param dataItemId
     * @return
     * @throws Exception
     */
    Map<String, Object> delDataItem(String dataItemId) throws Exception;

    /**
     * @param  version
     * @return 根据操作单元或者一站一案
     * @mark 备注 已经废弃 ， 暂时保存
     */
    Map<String, Object> cloneStepVersion(Version version , boolean isWorkCell,Employee employee) throws Exception;


    /**
     * 根据操作单元删除步骤
     */
    Map<String,Object> delStepByCellId(String cellId) throws Exception;


    /***
     * 根据阶段删除步骤
     * @param type
     * @param stepId
     * @return
     */
    Map<String,Object> delStepByStepId(Integer type,String stepId) throws Exception;


    /**
     * 添加步骤
     * @param singleWorkSteps
     * @return
     * @throws Exception
     */
    Map<String,Object> addStep(List<SingleWorkStep> singleWorkSteps,String cellId,Employee employee) throws Exception;

    /**
     * 得到操作单元 或者 一站一案 操作步骤
     * @param cellId 操作单元Id 或者一站一案Id
     * @param stepVersion 版本号
     * @param isStatus 状态 {修改，详情}
     * @param backTarget 用来判断是否是一站一案或者操作单元
     */
    List<SingleWorkStep> getStepByCellId(String cellId,String stepVersion,String isStatus,String backTarget);

    /**
     * 根据cellId和版本查询步骤
     * @param singleWorkStep
     * @return
     */
    List<SingleWorkStep> getStepsByCellIdAndVersion(SingleWorkStep singleWorkStep);

    /**
     * 分析操作卡情况
     * @param singleWorkStep
     * @return
     */
    List<SingleWorkStep> getAnalysisSteps(SingleWorkStep singleWorkStep,int longgestStep);

}
